﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Coolzon.UI.Core.Runtime.Script
{
    /// <summary>
    /// 用于供脚本操作时间的类
    /// </summary>
    public class DateScriptObject
    {
        DateTime _dateTime;
        public DateScriptObject()
        {
            _dateTime = DateTime.Now;
        }

        /// <summary>
        /// 获取当前时间
        /// </summary>
        /// <returns></returns>
        public DateScriptObject now()
        {
            _dateTime = DateTime.Now;
            return this;
        }

        /// <summary>
        /// 添加一定天数
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        public DateScriptObject addDay(int day)
        {
            this._dateTime = this._dateTime.AddDays(day);
            return this;
        }

        /// <summary>
        /// 添加一定月份
        /// </summary>
        /// <param name="Month"></param>
        /// <returns></returns>
        public DateScriptObject addMonth(int Month)
        {
            this._dateTime = this._dateTime.AddMonths(Month);
            return this;
        }

        /// <summary>
        /// 添加一定年份
        /// </summary>
        /// <param name="Year"></param>
        /// <returns></returns>
        public DateScriptObject addYear(int Year)
        {
            this._dateTime = this._dateTime.AddYears(Year);
            return this;
        }

        /// <summary>
        /// 获取月份
        /// </summary>
        /// <returns></returns>
        public int getMonth()
        {
            return this._dateTime.Month;
        }

        /// <summary>
        /// 获取年份
        /// </summary>
        /// <returns></returns>
        public int getYear()
        {
            return this._dateTime.Year;
        }

        //public override string ToString()
        //{
        //    return this._dateTime.ToString();
        //}

        //public string toString()
        //{
        //    return this._dateTime.ToString();
        //}

        public string toString(string format)
        {
            return this._dateTime.ToString(format);
        }

        public string toString()
        {
            return this._dateTime.ToString();
        }
    }
}
